namespace SmartSoft.Invoices
{
    using SmartSoft;
    using Stimulsoft.Report;
    using System;
    using System.Data;
    using System.Globalization;
    using System.IO;
    using System.Windows.Forms;

    public class SSPrintInvoiceLib
    {
        private StiReport oReport;

        private DataTable MakeBarcodeInvoiceTable(DataTable po_Source)
        {
            DataTable table = new DataTable();
            DataColumn column = new DataColumn("Ma_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ten_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Dvt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("So_Luong", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Gia9", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Tien9", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Kho", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ten_Kho", typeof(string));
            table.Columns.Add(column);
            table.PrimaryKey = new DataColumn[] { table.Columns["Ma_Vt"], table.Columns["Gia9"] };
            foreach (DataRow row2 in po_Source.Rows)
            {
                object[] keys = new object[] { row2["Ma_Vt"], row2["Gia9"] };
                DataRow row = table.Rows.Find(keys);
                if (row == null)
                {
                    row = table.NewRow();
                    row["Ma_Vt"] = row2["Ma_Vt"];
                    row["Ten_Vt"] = row2["Ten_Vt"];
                    row["Dvt"] = row2["Dvt"];
                    row["Ma_Kho"] = row2["Ma_Kho"];
                    row["Ten_Kho"] = row2["Ten_Kho"];
                    row["Gia9"] = row2["Gia9"];
                    row["So_Luong"] = 0;
                    row["Tien9"] = 0;
                }
                row["So_Luong"] = ((decimal) row["So_Luong"]) + ((decimal) row2["So_Luong"]);
                row["Tien9"] = ((decimal) row["Tien9"]) + ((decimal) row2["Tien9"]);
                if (row.RowState == DataRowState.Detached)
                {
                    table.Rows.Add(row);
                }
            }
            return table;
        }

        private DataTable MakeBarcodeOutInventoryTable(DataTable po_Source)
        {
            DataTable table = new DataTable();
            DataColumn column = new DataColumn("Ma_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ten_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Dvt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("So_Luong", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Gia9", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Kho", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ten_Kho", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Ke", typeof(string));
            table.Columns.Add(column);
            table.PrimaryKey = new DataColumn[] { table.Columns["Ma_Vt"], table.Columns["Ma_Ke"], table.Columns["Gia9"] };
            foreach (DataRow row2 in po_Source.Rows)
            {
                object[] keys = new object[] { row2["Ma_Vt"], row2["Ma_Ke"], row2["Gia9"] };
                DataRow row = table.Rows.Find(keys);
                if (row == null)
                {
                    row = table.NewRow();
                    row["Ma_Vt"] = row2["Ma_Vt"];
                    row["Ten_Vt"] = row2["Ten_Vt"];
                    row["Dvt"] = row2["Dvt"];
                    row["Ma_Kho"] = row2["Ma_Kho"];
                    row["Ten_Kho"] = row2["Ten_Kho"];
                    row["Ma_Ke"] = row2["Ma_Ke"];
                    row["Gia9"] = row2["Gia9"];
                    row["So_Luong"] = 0;
                }
                row["So_Luong"] = ((decimal) row["So_Luong"]) + ((decimal) row2["So_Luong"]);
                if (row.RowState == DataRowState.Detached)
                {
                    table.Rows.Add(row);
                }
            }
            return table;
        }

        public void OnBarcodeInvoicePrint(SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_Nt0"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport["So_Ct_List"] = po_InvoiceLib.SSInvoiceMethod.CtVAT_So_Ct0_List(po_MasterRow["Stt"]);
                if (AppInstance.LotNumberCtrl)
                {
                    this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                    this.StimulReport.RegData("CTVT0", this.MakeBarcodeInvoiceTable(po_DetailTable));
                }
                else
                {
                    this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                    this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                }
                this.OnPrint(true);
            }
        }

        public void OnBarcodeOutInventoryPrint(SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                if (AppInstance.LotNumberCtrl)
                {
                    this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                    this.StimulReport.RegData("CTVT0", this.MakeBarcodeOutInventoryTable(po_DetailTable));
                }
                else
                {
                    this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                    this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                }
                this.OnPrint(true);
            }
        }

        public void OnCTBGPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_Nt"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTBHPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                DataTable table = po_InvoiceLib.JournalEntry(po_DetailTable);
                string str = "";
                string str2 = "";
                string str3 = "";
                po_InvoiceLib.MakeTransList(ref str, ref str2, ref str3, table);
                this.StimulReport["Tk_No_Co"] = str;
                this.StimulReport["TkList"] = str2;
                this.StimulReport["Tien_NtList"] = str3;
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_Nt0"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport["So_Ct_List"] = po_InvoiceLib.SSInvoiceMethod.CtVAT_So_Ct0_List(po_MasterRow["Stt"]);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTDHPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_Nt"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTKHOPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                if ((po_InvoiceLib.InvoiceCode == "CTBG" || po_InvoiceLib.InvoiceCode == "CCBG") && (!po_MasterRow["Hinh_Thuc"].Equals("N")))
                {
                    this.UpdateParametersOther(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                }
                else
                {
                    this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                }
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTKTPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                DataTable table = po_InvoiceLib.JournalEntry(po_DetailTable);
                string str = "";
                string str2 = "";
                string str3 = "";
                po_InvoiceLib.MakeTransList(ref str, ref str2, ref str3, table);
                this.StimulReport["Tk_No_Co"] = str;
                this.StimulReport["TkList"] = str2;
                this.StimulReport["Tien_NtList"] = str3;
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_NtN"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport["So_Ct_List"] = po_InvoiceLib.SSInvoiceMethod.CtVAT_So_Ct0_List(po_MasterRow["Stt"]);
                //if (po_InvoiceLib.InvoiceCode == "NHBN")
                //{
                //    object obj2 = null;
                //    object obj3 = null;
                //    object obj4 = null;
                //    object obj5 = null;
                //    object obj6 = null;
                //    object obj7 = null;
                //    object obj8 = null;
                //    object obj9 = null;
                //    po_InvoiceLib.SSInvoiceMethod.GetBankAccount(po_MasterRow["Stt"], ref obj2, ref obj3, ref obj4, ref obj5, ref obj6, ref obj7, ref obj8, ref obj9);
                //    //FormCTKTUNCEditor editor = new FormCTKTUNCEditor(obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9);
                    //editor.ShowDialog();
                    //if (!editor.CheckAccepted)
                    //{
                    //    return;
                    //}
                    //obj2 = editor.Ten_Dvi_A;
                    //obj3 = editor.Tk_NH_A;
                    //obj4 = editor.Ten_NH_A;
                    //obj5 = editor.Ten_TP_A;
                    //obj6 = editor.Ten_Dvi_B;
                    //obj7 = editor.Tk_NH_B;
                    //obj8 = editor.Ten_NH_B;
                    //obj9 = editor.Ten_TP_B;
                    //po_InvoiceLib.SSInvoiceMethod.SaveBankAccount(po_MasterRow["Stt"], obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9);
                    //this.StimulReport["Ten_Dvi_A"] = obj2;
                    //this.StimulReport["Tk_NH_A"] = obj3;
                    //this.StimulReport["Ten_NH_A"] = obj4;
                    //this.StimulReport["Ten_TP_A"] = obj5;
                    //this.StimulReport["Ten_Dvi_B"] = obj6;
                    //this.StimulReport["Tk_NH_B"] = obj7;
                    //this.StimulReport["Ten_NH_B"] = obj8;
                    //this.StimulReport["Ten_TP_B"] = obj9;
                //}
                this.StimulReport.RegData("CTKT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTKT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTMHPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                DataTable table = po_InvoiceLib.JournalEntry(po_DetailTable);
                string str = "";
                string str2 = "";
                string str3 = "";
                po_InvoiceLib.MakeTransList(ref str, ref str2, ref str3, table);
                this.StimulReport["Tk_No_Co"] = str;
                this.StimulReport["TkList"] = str2;
                this.StimulReport["Tien_NtList"] = str3;
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_Nt0"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport["So_Ct_List"] = po_InvoiceLib.SSInvoiceMethod.CtVAT_So_Ct0_List(po_MasterRow["Stt"]);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTNBPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTNXPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                DataTable table = po_InvoiceLib.JournalEntry(po_DetailTable);
                string str = "";
                string str2 = "";
                string str3 = "";
                po_InvoiceLib.MakeTransList(ref str, ref str2, ref str3, table);
                this.StimulReport["Tk_No_Co"] = str;
                this.StimulReport["TkList"] = str2;
                this.StimulReport["Tien_NtList"] = str3;
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien_Nt0"], po_MasterRow["Ma_Tte"], AppInstance.FCAmountDecimals);
                this.StimulReport["So_Ct_List"] = po_InvoiceLib.SSInvoiceMethod.CtVAT_So_Ct0_List(po_MasterRow["Stt"]);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTSXPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTTPPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(po_MasterRow["TTien0"], AppInstance.DefaultCurrency, AppInstance.LCAmountDecimals);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTVATPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.StimulReport["NumToWordsVN"] = AppInstance.NumToWordVN(((decimal) po_MasterRow["Tien"]) + ((decimal) po_MasterRow["Tien3"]), AppInstance.DefaultCurrency, AppInstance.LCAmountDecimals);
                this.StimulReport.RegData(po_MasterRow.Table);
                this.OnPrint(pb_Printed);
            }
        }

        public void OnCTYCMPrint(bool pb_Printed, SSInvoiceLib po_InvoiceLib, DataRow po_MasterRow, DataTable po_DetailTable)
        {
            if ((!string.IsNullOrEmpty(po_InvoiceLib.ReportFileName) && po_InvoiceLib.AllowViewInvoice) && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))
            {
                this.UpdateParameters(po_InvoiceLib.ReportFileName, po_InvoiceLib.InvoiceTitle, po_InvoiceLib.InvoiceSerial);
                this.StimulReport.RegData("CTVT", po_MasterRow.Table.Copy());
                this.StimulReport.RegData("CTVT0", po_DetailTable.Copy());
                this.OnPrint(pb_Printed);
            }
        }

        public void OnDesign(SSInvoiceLib po_InvoiceLib)
        {
            if (((!AppInstance.CheckTrialVersion && !string.IsNullOrEmpty(po_InvoiceLib.ReportFileName)) && (po_InvoiceLib.AllowViewInvoice && File.Exists(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt"))) && po_InvoiceLib.AllowViewInvoice)
            {
                this.StimulReport.Load(AppInstance.UserReportPath + po_InvoiceLib.ReportFileName + ".mrt");
                this.StimulReport.Design();
            }
        }

        private void OnPrint(bool pb_Printed)
        {
            Application.DoEvents();
            if (pb_Printed)
            {
                this.StimulReport.Print();
            }
            else
            {
                this.StimulReport.Show();
            }
        }

        private void UpdateParameters(string ps_ReportFile, string ps_ReportTitle, string ps_ReportSerial)
        {
            if (this.StimulReport != null)
            {
                this.StimulReport.Load(AppInstance.UserReportPath + ps_ReportFile + ".mrt");
                this.StimulReport.Compile();
                this.StimulReport["DEMOString"] = AppInstance.DEMOString;
                this.StimulReport["DatePrinted"] = (AppInstance.ShowDateTime == 1) || (AppInstance.ShowDateTime == 3);
                this.StimulReport["ReportTitle"] = ps_ReportTitle.ToUpper();
                this.StimulReport["CompanyName"] = AppInstance.NameOfEnterprise;
                this.StimulReport["CompanyAddress"] = AppInstance.AddressOfEnterprise;
                this.StimulReport["DecimalSymbol"] = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
                this.StimulReport["GroupingSymbol"] = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
                this.StimulReport["PSo_Luong_Decim"] = AppInstance.QuantityDecimals;
                this.StimulReport["PSo_LuongDM_Decim"] = AppInstance.NormQuantity;
                this.StimulReport["PSo_LuongHS_Decim"] = AppInstance.RatioFormat;
                this.StimulReport["NegativePattern"] = NumberFormatInfo.CurrentInfo.NumberNegativePattern;
                this.StimulReport["PGia_Decim"] = AppInstance.LCPriceDecimals;
                this.StimulReport["PGia_Nt_Decim"] = AppInstance.FCPriceDecimals;
                this.StimulReport["PTy_Gia_Decim"] = AppInstance.ExchangeFormat;
                this.StimulReport["PTien_Decim"] = AppInstance.LCAmountDecimals;
                this.StimulReport["PTien_Nt_Decim"] = AppInstance.FCAmountDecimals;
                if (!string.IsNullOrEmpty(ps_ReportSerial))
                {
                    this.StimulReport["TheDecisionNumber"] = "Mẫu số: " + ps_ReportSerial;
                    if (ps_ReportSerial.Trim().ToUpper().Substring(0, 4) != "NHCSXH")
                    {
                        this.StimulReport["TheFirstRowDecision"] = AppInstance.FirstRowReport;
                        this.StimulReport["TheSecondRowDecision"] = AppInstance.SecondRowReport;
                        this.StimulReport["TheThirdRowDecision"] = AppInstance.ThirdRowReport;
                    }
                }
            }
        }
        private void UpdateParametersOther(string ps_ReportFile, string ps_ReportTitle, string ps_ReportSerial)
        {
            if (this.StimulReport != null)
            {
                this.StimulReport.Load(AppInstance.UserReportPath + "BGTS.mrt");
                this.StimulReport.Compile();
                this.StimulReport["DEMOString"] = AppInstance.DEMOString;
                this.StimulReport["DatePrinted"] = (AppInstance.ShowDateTime == 1) || (AppInstance.ShowDateTime == 3);
                this.StimulReport["ReportTitle"] = ps_ReportTitle.ToUpper();
                this.StimulReport["CompanyName"] = AppInstance.NameOfEnterprise;
                this.StimulReport["CompanyAddress"] = AppInstance.AddressOfEnterprise;
                this.StimulReport["DecimalSymbol"] = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
                this.StimulReport["GroupingSymbol"] = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
                this.StimulReport["PSo_Luong_Decim"] = AppInstance.QuantityDecimals;
                this.StimulReport["PSo_LuongDM_Decim"] = AppInstance.NormQuantity;
                this.StimulReport["PSo_LuongHS_Decim"] = AppInstance.RatioFormat;
                this.StimulReport["NegativePattern"] = NumberFormatInfo.CurrentInfo.NumberNegativePattern;
                this.StimulReport["PGia_Decim"] = AppInstance.LCPriceDecimals;
                this.StimulReport["PGia_Nt_Decim"] = AppInstance.FCPriceDecimals;
                this.StimulReport["PTy_Gia_Decim"] = AppInstance.ExchangeFormat;
                this.StimulReport["PTien_Decim"] = AppInstance.LCAmountDecimals;
                this.StimulReport["PTien_Nt_Decim"] = AppInstance.FCAmountDecimals;
                if (!string.IsNullOrEmpty(ps_ReportSerial))
                {
                    this.StimulReport["TheDecisionNumber"] = "Mẫu số: " + ps_ReportSerial;
                    if (ps_ReportSerial.Trim().ToUpper().Substring(0, 4) != "NHCSXH")
                    {
                        this.StimulReport["TheFirstRowDecision"] = AppInstance.FirstRowReport;
                        this.StimulReport["TheSecondRowDecision"] = AppInstance.SecondRowReport;
                        this.StimulReport["TheThirdRowDecision"] = AppInstance.ThirdRowReport;
                    }
                }
            }
        }
        private StiReport StimulReport
        {
            get
            {
                if (this.oReport == null)
                {
                    this.oReport = new StiReport();
                }
                return this.oReport;
            }
            set
            {
                if (this.oReport != value)
                {
                    this.oReport = value;
                }
            }
        }
    }
}

